package com.geek.bams.server;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/*
 *@author wangpeng
 *2025/10/28 18:57
 *@description TODO
 */
public class ATMSever extends JFrame{
    //JPanel界面
    ServerPanel serverPanel;
    RankPanel rankPanel;

    public ATMSever(){
        //设置窗体的基本信息
        this.setTitle("ATM Server");
        this.setSize(500,650);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
        this.setResizable(false);
        this.setLocationRelativeTo(null);

        //实例化JPanel界面（添加JPanel组件）
        serverPanel = new ServerPanel();
        rankPanel = new RankPanel();


        //将JPanel添加至JFrame窗体容器中
        Container container = this.getContentPane();
        //设置容器为卡片式布局
        container.setLayout(new CardLayout());
        //默认显示第一个
        container.add(serverPanel ,"serverPanel");
        container.add(rankPanel,"rankPanel");

        //添加窗口关闭事件：点击服务器的关闭按钮，直接退出
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

    }

    public static void main(String[] args) {
        new ATMSever().setVisible(true);
    }


}
